package com.fss.util;


import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONObject;

import com.fssDataModels.TbCmsContent;
import com.fssDataModels.TbUser;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public abstract class AbstractSimpleAction extends ActionSupport {

	

	private static final long serialVersionUID = 1L;
	
	protected int numOfResult=5;

	public abstract String initAdd() throws Exception;

	public abstract String doAdd() throws Exception;

	public abstract String initEdit() throws Exception;

	public abstract String doEdit() throws Exception;

	public abstract String doDelete() throws Exception;

	protected String msg;
	
	protected InputStream jsonStream;
	
	protected void setJsonMessage(String status, String message) {
		Map<String, String> msgMap = new HashMap<String, String>();
		msgMap.put("status", status);
		msgMap.put("message", message);
		String ajaxMsg = JSONObject.fromObject(msgMap).toString();
		this.jsonStream = new ByteArrayInputStream(ajaxMsg.getBytes());
	}

	
	public InputStream getJsonStream() {
		return jsonStream;
	}

	public void setJsonStream(InputStream jsonStream) {
		this.jsonStream = jsonStream;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getNumOfResult() {
		return numOfResult;
	}

	public void setNumOfResult(int numOfResult) {
		this.numOfResult = numOfResult;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	
}
